/***************************************************
Class: Input
Includes: stdafx.h
Editors: Gindi
Existing Issues: None
Description: Creates and returns input devices/information.
***************************************************/
#pragma once

#include "stdafx.h"

// device types
enum DIRECT_INPUT_TYPE {DIT_KEYBOARD, DIT_MOUSE, DIT_FORCE_DWORD = 0x7fffffff};

class InputDevice {
public:
	InputDevice();
	~InputDevice() { Release(); }

	bool Initialize(LPDIRECTINPUT8 pDI, HWND hWnd, DIRECT_INPUT_TYPE type, DWORD cooperativeLevel);
	void Release();
	void Read();
	void LockKey(DWORD key);

	long getX()				{ return m_x; }
	long getY()				{ return m_y; }
	long getChangeInX()		{ return m_mouseState.lX; }
	long getChangeInY()		{ return m_mouseState.lY; }
	long getChangeInZ()		{ return m_mouseState.lZ; }
	bool* getButtons()		{ return m_pressedButtons; }
	bool* getKeys()			{ return m_pressedKeys; }

private:
	LPDIRECTINPUTDEVICE8	m_pDevice;
	HWND					m_hWnd;
	DIRECT_INPUT_TYPE		m_type;
	char					m_keyboardState[256];
	bool					m_pressedKeys[256];
	DIMOUSESTATE			m_mouseState;
	bool					m_pressedButtons[4];
	bool					m_keyLock[256];
	long					m_x, m_y;
};
